import request from "@/utils/request";

// 查询运单列表
export function listWayBill(query) {
  return request({
    url: "/system/bill/list",
    method: "get",
    params: query,
  });
}

// 查询运单详细
export function getWayBill(id) {
  return request({
    url: "/system/bill/" + id,
    method: "get",
  });
}

// 新增运单
export function addWayBill(data) {
  return request({
    url: "/system/bill",
    method: "post",
    data: data,
  });
}

// 修改运单
export function updateWayBill(data) {
  return request({
    url: "/system/bill",
    method: "put",
    data: data,
  });
}

// 删除运单
export function delWayBill(ids) {
  return request({
    url: "/system/bill/" + ids,
    method: "delete",
  });
}

// 绑定定位器
export function bindLocator(id, locatorId, locatorCode) {
  return request({
    url: `/system/bill/${id}/bind-locator`,
    method: "put",
    params: {
      locatorId: locatorId,
      locatorCode: locatorCode,
    },
  });
}

// 解绑定位器
export function unbindLocator(id) {
  return request({
    url: `/system/bill/${id}/unbind-locator`,
    method: "put",
  });
}

// 统一解绑定位器（双向解绑）
export function unbindLocatorUnified(id) {
  return request({
    url: `/system/bill/${id}/unbind-locator-unified`,
    method: "put",
  });
}
